def ez(n):
    if n < 2:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

def vper(n):
    if n < 2:
        return 2
    while not ez(n):
        n += 1
    return n

def predu(n):
    if n < 2:
        return 2
    while not ez(n):
        n -= 1
    return n

def main():
    w = input().split()
    if len(w) != 3:
        print("Wrong input")
        return

    n = 0
    for word in w:
        if word == "zero":
            n = n * 10
        elif word == "one":
            n = n * 10 + 1
        elif word == "two":
            n = n * 10 + 2
        elif word == "three":
            n = n * 10 + 3
        elif word == "four":
            n = n * 10 + 4
        elif word == "five":
            n = n * 10 + 5
        elif word == "six":
            n = n * 10 + 6
        elif word == "seven":
            n = n * 10 + 7
        elif word == "eight":
            n = n * 10 + 8
        elif word == "nine":
            n = n * 10 + 9
        else:
            print("Wrong input")
            return


    c=[]
    c.append(ez(n))
    c.append(n)
    c.append(predu(n))
    if c[0]-c[1]<c[1]-c[2]:
        print(c[0])
    else:
        print(c[2])

if __name__ == "__main__":
    main()
